//与预约相关的逻辑
var appointingApp = angular.module("appointingApp", ["scService"]);
//开始预约
appointingApp.controller("beAppointingController", function($scope, $rootScope, $http, scCodeService, $location, $state, Popup, $stateParams, pubFun) {
    $rootScope.pageTitle = "预约";
    //$scope.loadingToastSet("预约中...");
    //$scope.loadingToastHide();
    //获取token
    var token = localStorage.getItem("token");
    //获取用户卡号
    var userCard = localStorage.getItem("cardNo");
    //獲取用戶id
    var userId = localStorage.getItem("userId");
    var chargerId = localStorage.getItem("charger_chargerId");
    //webSocket
    var webSocket = new WebSocket("ws://" + window.location.host + "/appserver/static/websocket/" + userId);
    webSocket.onerror = function(event) {

    };
    webSocket.onopen = function(event) {

    };
    webSocket.onmessage = function(event) {

        var websocketdata = JSON.parse(event.data);
        var websocketdata_data = JSON.parse(websocketdata.data);
        $scope.loadingToastHide();
        //
        if (websocketdata.action == "1001") { //预约成功推送
            reservationSn = websocketdata_data.reservationSn;
            //alert("websocket chargeSn:"+chargeSn);

            localStorage.setItem("reservationSn", reservationSn);
            window.location.href = mainConfig.hostUrl + "index.html?#/appointing/" + reservationSn;
        } else if (websocketdata.action == "1002") { //开启充电成功推送
            if (websocketdata_data.actionType == "1" || websocketdata_data.actionType == 1) {
                chargeSn = websocketdata_data.chargeSn;
                //alert("websocket chargeSn:"+chargeSn);

                localStorage.setItem("chargeSn", chargeSn);
                window.location.href = mainConfig.hostUrl + "index.html?#/charging/" + chargeSn;
            }
        } else if (websocketdata.action == "1003") { //结束充电成功推送
            var orderNo = websocketdata_data.orderNo;
            localStorage.setItem("orderNo", orderNo);
            //alert("websocket orderNo:"+orderNo);

            $scope.openCharge = "false";
            localStorage.setItem("openCharge", $scope.openCharge);
            window.location.href = mainConfig.hostUrl + "index.html?#/orderPay/" + orderNo;
        }

    };
    //获取桩站信息
    $scope.getChargerDetail = function() {
        $scope.qrCode = $stateParams.chargerId;

        var postData = {
            qrCode: $scope.qrCode
        }
        scCodeService.getChargerDetailByQrCode(postData).then(function(data) {

            if (data.code == "200") {
                if (data.data) {
                    $scope.chargerDetail = data.data;

                    //组装桩类型数据
                    if ($scope.chargerDetail.chargerType == "1") {
                        $scope.chargerDetailType = "直流 快充"
                    } else if ($scope.chargerDetail.chargerType == "2") {
                        $scope.chargerDetailType = "交流220V 慢充"
                    }
                    pubFun.getRate($scope.chargerDetail.chargerId).then(function(data) {
                        $scope.mainRate = data;
                    });
                }
            } else {
                Popup.notice('获取桩信息失败', 3000, function() {

                });
            }
        })
    }
    $scope.getChargerDetail();
    //获取预约费率
    /*$scope.getRate = function() {
        var postData = {
            chargerId: $scope.chargerDetail.chargerId
        }
        $scope.mainRate = {};
        scCodeService.getRate(postData).then(function(data) {
            if (data.code == "200") {
                //费率处理
                for (var i = 0; i < data.data.length; i++) {
                    if (data.data[i].feeType == "3") {
                        $scope.mainRate.serveRate = data.data[i].rate;
                        $scope.mainRate.serveMode = data.data[i].chargeMode;
                        $scope.mainRate.serveModeStr= data.data[i].chargeMode=="0"?"分钟":"次";
                    } else if (data.data[i].feeType == "2") {
                        $scope.mainRate.chargerRate = data.data[i].rate;
                        $scope.mainRate.chargerMode = data.data[i].chargeMode;
                    } else if (data.data[i].feeType == "1") {
                        $scope.mainRate.reservationRate = data.data[i].rate;
                        $scope.mainRate.reservationMode = data.data[i].chargeMode;
                        $scope.mainRate.reservationModeStr = data.data[i].chargeMode=="0"?"分钟":"次";
                    }
                }

            } else {
                Popup.notice('获取桩信息失败', 3000, function() {
                    
                });
            }
        });

    }*/

    //开始导航
    $scope.satNavigation = function(address) {
            var latitude = localStorage.getItem("latitude");
            var longitude = localStorage.getItem("longitude");
            //alert("latitude"+latitude+",longitude"+longitude);
            window.location.href = "https://map.qq.com/m/mqq/nav/eword=" + address + "&epointx=" + longitude + "&epointy=" + latitude + "?referer=myapp&key=P44BZ-LANRX-D6I46-ZTXJL-OHJT2-LKBR3";
        }
        //开始预约
    $scope.startReservation = function() {
        $scope.loadingToastSet("预约中...");
        var postData = {
                userCard: userCard,
                chargerId: $scope.chargerDetail.chargerId,
                plugNo: $scope.chargerDetail.plugNoList[0].portNo
            }
            //alert(JSON.stringify(postData));
        scCodeService.startReservation(postData).then(function(data) {
            //alert(JSON.stringify(data));
            if (data.code == "200") {
                localStorage.setItem("chargerDetail", JSON.stringify($scope.chargerDetail));
                localStorage.setItem("mainRate", JSON.stringify($scope.mainRate));
                //等待预约成功推送，如超过20s则调用查询正在进行中的业务查询接口，跳转至预约中界面，如查询无果，则跳转至我的订单中进行中tab
                var num = 0;
                var pushTimeout = setInterval(function() {
                    num++;
                    if (num > mainConfig.overTimeSeconds) {

                        // alert("+++");
                        clearInterval(pushTimeout);

                        var postData = { userCard: userCard }
                        scCodeService.getOngoingOperation(postData).then(function(data) {

                            if (data.code == "200") {
                                if (data.data) {
                                    $scope.reservationSn = data.data.reservationList.reservationSn;
                                    window.location.href = mainConfig.hostUrl + "index.html?#/appointing/" + $scope.reservationSn;
                                }
                            } else {
                                $location.path("/myOrder/processing");
                            }
                        })

                    }
                }, 1000);
            } else if (data.code == "0201028") {
                $scope.loadingToastHide();
                Popup.notice('您有未支付的订单，不能进行预约', 3000, function() {

                });
            } else {
                $scope.loadingToastHide();
                Popup.notice(data.msg, 3000, function() {

                });
            }
        });
    }
});

//预约中
appointingApp.controller("appointingController", function($scope, $rootScope, $timeout, $http, scCodeService, $location, $state, Popup, $stateParams) {
    //$scope.loadingToastSet("订单推送中...");
    //$scope.loadingToastHide();
    //获取token
    var token = localStorage.getItem("token");
    //获取用户卡号
    var userCard = localStorage.getItem("cardNo");
    //獲取用戶id
    var userId = localStorage.getItem("userId");
    //是否正在充电
    var openCharge = localStorage.getItem("openCharge");
    $scope.isReservationNotOverTime = "true"; //预约是否超时
    $scope.estimatesFee = 0; //计算预约费用
    $scope.surplusTime = ''; //计算预约剩余时间
    var pushTimeout = ''; //计算开启充电超时
    //webSocket
    var webSocket = new WebSocket("ws://" + window.location.host + "/appserver/static/websocket/" + userId);
    webSocket.onerror = function(event) {

    };
    webSocket.onopen = function(event) {

    };
    webSocket.onmessage = function(event) {

        //alert(event.data);
        var websocketdata = JSON.parse(event.data);
        var websocketdata_data = JSON.parse(websocketdata.data);
        $scope.loadingToastHide();
        //
        if (websocketdata.action == "1001") { //预约成功推送
            reservationSn = websocketdata_data.reservationSn;
            //alert("websocket chargeSn:"+chargeSn);

            localStorage.setItem("reservationSn", reservationSn);
            window.location.href = mainConfig.hostUrl + "index.html?#/appointing/" + reservationSn;
        } else if (websocketdata.action == "1002") { //开启充电成功推送
            if (websocketdata_data.actionType == "1" || websocketdata_data.actionType == 1) {
                chargeSn = websocketdata_data.chargeSn;
                //alert("websocket chargeSn:"+chargeSn);

                $rootScope.showWeird = false;
                mainConfig.isNotPushFlag = false;
                localStorage.setItem("chargeSn", chargeSn);
                window.location.href = mainConfig.hostUrl + "index.html?#/charging/" + chargeSn;
            }
        } else if (websocketdata.action == "1003") { //结束充电成功推送
            var orderNo = websocketdata_data.orderNo;
            localStorage.setItem("orderNo", orderNo);
            //alert("websocket orderNo:"+orderNo);

            $scope.openCharge = "false";
            localStorage.setItem("openCharge", $scope.openCharge);
            mainConfig.isNotPushFlag = false;
            $rootScope.showWeird = false;
            window.location.href = mainConfig.hostUrl + "index.html?#/orderPay/" + orderNo;
        }

    };
    //价格数据处理，从2处理成2.00格式
    $scope.intToFloat = function(num) {
            num = Math.round(num * 100) / 100;
            var obj = num.toString().split(".");
            if (obj.length == 1) {
                num = num + '.00';
            } else {
                if (obj[1].length == 1) {
                    num = num + '0';
                }
            }
            return num;

        }
        //获取基本显示信息
    $scope.getChargerDetail = function() {
        // 获取桩站详情
        $scope.chargerDetail = localStorage.getItem("chargerDetail"); //获取缓存的桩站信息
        if ($scope.chargerDetail != null && $scope.chargerDetail != "" && $scope.chargerDetail != "undefined") {
            $scope.chargerDetail = JSON.parse($scope.chargerDetail);
        } else {
            $location.path("/index_");
        }

        //组装桩类型数据
        if ($scope.chargerDetail.chargerType == "1") {
            $scope.chargerDetailType = "直流 快充"
        } else if ($scope.chargerDetail.chargerType == "2") {
            $scope.chargerDetailType = "交流220V 慢充"
        }

        //获取费率
        $scope.mainRate = localStorage.getItem("mainRate"); //获取缓存的桩站信息
        if ($scope.mainRate != null && $scope.mainRate != "" && $scope.mainRate != "undefined") {
            $scope.mainRate = JSON.parse($scope.mainRate);
        }

        //获取预约信息
        if ($stateParams.appointingId) {
            $scope.appointingId = $stateParams.appointingId;
        }
        var postData = { userCard: userCard }
        scCodeService.getOngoingOperation(postData).then(function(data) {

            if (data.code == "200") {
                if (data.data) {
                    $scope.appointDetail = data.data.reservationList[0];
                    //组装预约剩余时间和费用、开始时间
                    var st = new Date();
                    st.setTime($scope.appointDetail.startTime);
                    var hours = st.getHours();
                    if(hours < 10){
                        hours = "0" + hours;
                    }
                    var minutes = st.getMinutes();
                    if(minutes < 10){
                        minutes = "0" + minutes;
                    }
                    var seconds = st.getSeconds();
                    if(seconds  < 10){
                        seconds  = "0" + seconds;
                    }
                    $scope.appointStartTime = st.getFullYear() + "-" + (st.getMonth() + 1) + "-" + st.getDate() + " " + hours + ":" + minutes + ":" + seconds;
                    var nowTime = new Date(); //获取当前时间
                    current = (nowTime.getTime() - $scope.appointDetail.startTime) / 1000; //计算当前时间与开始时间的时间差
                    current = current / 60;
                    var total = 6 * 60;
                    $scope.timer = function() {
                        if (current < total) {
                            $scope.estimatesFee = $scope.intToFloat(current * $scope.mainRate.reservationRate);
                            var leave1 = parseInt(total - current) % (24 * 3600);
                            var sh = Math.floor(leave1 / 60) + "小时";
                            var leave2 = leave1 % 60;
                            var sm = Math.floor(leave2) + "分钟";
                            $scope.surplusTime = sh + sm;
                            $timeout(function() {
                                $scope.timer()
                            }, 60000);
                        } else { //若预约超时，则隐藏开始充电按钮
                            clearInterval(surplusTimeSet);
                            $scope.loadingToastSet("订单生成中...");
                            $scope.surplusTime = "预约超时";
                            $scope.estimatesFee = $scope.intToFloat(total * $scope.mainRate);
                            $scope.isReservationNotOverTime = "false";
                            //订单推送超时处理
                            //$scope.orderPushTimeOut();

                        }
                        if ($scope.mainRate.reservationMode == "0") {

                        } else {
                            $scope.estimatesFee = $scope.mainRate.reservationRate;
                        }
                        current++;
                    };
                    $scope.timer();

                }
            } else {
                Popup.notice('获取预约信息失败', 3000, function() {

                });
            }
        })

    }
    $scope.getChargerDetail();
    //开始导航
    $scope.satNavigation = function(address) {
            var latitude = localStorage.getItem("latitude");
            var longitude = localStorage.getItem("longitude");
            //alert("latitude"+latitude+",longitude"+longitude);
            window.location.href = "https://map.qq.com/m/mqq/nav/eword=" + address + "&epointx=" + longitude + "&epointy=" + latitude + "?referer=myapp&key=P44BZ-LANRX-D6I46-ZTXJL-OHJT2-LKBR3";
        }
        //取消预约
    $scope.cancelReservation = function() {
            mainConfig.isNotPushFlag = true;
            $scope.weirdConfirmSet({
                title: "",
                content: "确定要取消预约？",
                buttonAux: '点错了',
                buttonMain: '确定',
                icon: "excl",
                data: { type: "1", reservationSn: $scope.appointDetail.reservationSn } //type: "1"，取消预约 "2"，结束充电
            });
        }
        // confirm确定取消预约
        /*$rootScope.confirmSure = function(data) {
            $scope.loadingToastSet("取消预约中...");
            var postData = {
                reservationSn: $scope.appointDetail.reservationSn
            }
            //alert($scope.appointDetail.reservationSn);
            scCodeService.cancelReservation(postData).then(function(data) {
                //alert(JSON.stringify(data));
                
                if (data.code == "200") {
                    $rootScope.showWeird = false;
                    //订单推送超时处理
                    $scope.orderPushTimeOut();
                    //取消预约成功，清除预约信息缓存
                    localStorage.setItem("chargerDetail", "");
                    localStorage.setItem("mainRate", "");
                } else {
                    $scope.loadingToastHide();
                    Popup.notice('取消失败', 3000, function() {
                        
                    });
                }
            })
        };
        //订单推送超时处理，则获取未支付的订单，有则跳转至支付界面，无则跳转至我的未支付订单界面
        $scope.orderPushTimeOut = function() {
                var num = 0;
                var pushTimeout = setInterval(function() {
                    num++;
                    if (num > mainConfig.overTimeSeconds) {
                        clearInterval(pushTimeout);
                        var postData = {
                            userId: userId,
                            status: "0"
                        }
                        scCodeService.getFundList(postData).then(function(data) {
                            $scope.loadingToastHide();
                            if (data.code == "200") {
                                if (data.data.length !== 0) {
                                    $scope.notPayCardNo = data.data[0].orderNo;
                                    window.location.href = mainConfig.hostUrl + "index.html?#/orderPay/" + $scope.notPayCardNo;
                                } else {
                                    $location.path("/myOrder/pending");
                                }
                            }
                        })
                    }
                }, 1000);
            }*/
        //点击开始充电
    $scope.startCharge = function(argument) {
            $scope.isStartCharge = true;
        }
        //取消充电
    $scope.noClose = function(argument) {
            $scope.isStartCharge = false;
        }
        //点击开始充电
    $scope.startChargeConfirm = function() {
        $scope.isStartCharge = false;
        var postData = {
            chargerId: $scope.chargerDetail.chargerId,
            userCard: userCard,
            chargerPlugNo: $scope.chargerDetail.plugNoList[0].portNo,
            token: token,
            source: mainConfig.source,
            merchantCode: mainConfig.merchantCode
        };
        $scope.loadingToastSet("开启充电中...");
        scCodeService.openCharge(postData).then(function(data) {


            if (data.code == "200") {
                $scope.isStartCharge = false;
                //开启充电成功，清除预约信息缓存
                localStorage.setItem("chargerDetail", "");
                localStorage.setItem("mainRate", "")
                    //获取开始时间
                var temp = new Date();
                var Y = temp.getFullYear() + '-';
                var M = (temp.getMonth() + 1 < 10 ? '0' + (temp.getMonth() + 1) : temp.getMonth() + 1) + '-';
                var D = temp.getDate() + ' ';
                var h = temp.getHours();
                if (h < 10) {
                    h = "0" + h;
                }
                var m = temp.getMinutes();
                if (m < 10) {
                    m = "0" + m;
                }
                var s = temp.getSeconds();
                if (s < 10) {
                    s = "0" + s;
                }
                var result = Y + M + D + h + ":" + m + ":" + s;
                var SMS = Date.parse(temp);
                // var regex = /\//g;
                // var result = (temp.toLocaleDateString("zh-cn") + ' ' + temp.toLocaleTimeString("en-GB",{hour12: false})).replace(regex, '-');
                localStorage.setItem("SMS", SMS);

                localStorage.setItem("startTime", result);
                //判断充电开启状态
                $scope.openCharge = "true";
                localStorage.setItem("openCharge", $scope.openCharge);
                localStorage.setItem("chargerDetail", JSON.stringify($scope.chargerDetail));
                //chargerId and plugNo
                localStorage.setItem("chargerId", $scope.chargerDetail.chargerId);
                localStorage.setItem("plugNo", $scope.chargerDetail.plugNoList.portNo);
                localStorage.setItem("rate", $scope.mainRate.chargerRate);

                //开启充电推送超时处理
                var num = 0;
                pushTimeout = setInterval(function() {
                    num++;
                    if (num > mainConfig.overTimeSeconds) {
                        clearInterval(pushTimeout);
                        pubFun.getOngoingOperation().then(function(data) {
                            if (globalFun.isEmptyObj(data.chargeList) == false) { //如果存在正在充电的业务
                                angular.forEach($scope.chargeList, function(data, index, array) {
                                    $scope.loadingToastHide();
                                    if (array[index].chargerId == postData.chargerId && array[index].portNo == postData.chargerPlugNo) { //进行桩和枪口的匹配
                                        window.location.href = mainConfig.hostUrl + 'index.html?#/charging/' + array[index].chargeSn;
                                    }
                                });

                            }
                        });
                    }
                }, 1000);
            } else {
                $scope.loadingToastHide();
                Popup.notice('充电桩不可用', 3000, function() {

                });
            }
        })
    }
});

// 站点详情
appointingApp.controller('stateDetailController', function($scope, $rootScope, $filter, $rootScope, $q, scCodeService, $location, $state, $stateParams, pubFun) {
    document.getElementById("loadingToast1").style.display = "none";
    //当前城市和选择城市
    $scope.selectedCity = JSON.parse(localStorage.getItem("currentCity"));
    $scope.currentCity = JSON.parse(localStorage.getItem("city"));
    // tab 切换
    $scope.stateTab = 0;
    $scope.pileD = false;
    $scope.pileC = true;
    $scope.stateFun = function(index) {
        $scope.stateTab = index;
        $scope.pileC = $scope.stateTab == 0 ? true : false;
        $scope.pileD = $scope.stateTab == 0 ? false : true;
    };
    //获取token
    var token = localStorage.getItem("token");
    //获取用户卡号
    var userCard = localStorage.getItem("cardNo");
    //獲取用戶id
    var userId = localStorage.getItem("userId");
    $scope.stationId = $stateParams.stationId;

    //$rootScope.getStationDetail();
    pubFun.getStationDetail($scope.stationId).then(function(data) {
        $scope.stationDetail = data;
        // $scope.collectBtn =data.collectionFlag=="0"?"收藏":"取消";
        if (data.collectionFlag == "0") {
            $scope.activeStyle = 1;
            $scope.collectBtn = "收藏";
        } else {
            $scope.activeStyle = 0;
            $scope.collectBtn = "取消";
        }
        $scope.score = data.score / 2;
        localStorage.setItem("latitude", $scope.stationDetail.latitude);
        localStorage.setItem("longitude", $scope.stationDetail.longitude);
    });
    //桩位
    $scope.getChargerListByStationId = function() {
        $scope.isACFree = "1";
        $scope.isDCFree = "1";
        $scope.isACFreeNight = false;
        $scope.isDCFreeNight = false;
        $scope.distancestr = '';
        $scope.distance = $stateParams.distance;
        if ($scope.distance != "0" && $scope.distance != 0) {
            $scope.distancestr = $scope.distance;
        }
        scCodeService.getChargerListByStationId($scope.stationId).then(function(data) {
            if (data.code == "200") {
                if (data.data) {
                    $scope.orderNum = function(num) {
                        return Number(num.plugNoList[0].chargeStatus);
                    };
                    $scope.chargerList = data.data;
                    //定义数组
                    $scope.chargeStatusFree = [];
                    $scope.chargeStatusNo = [];
                    //查询本站桩是否空闲
                    angular.forEach($scope.chargerList, function(data, index, array) {
                        if (array[index].plugNoList[0].chargeStatus == "0" && array[index].chargerType == "2") {
                            $scope.isACFree = "0";
                            $scope.isACFreeNight = true;
                        }
                        if (array[index].plugNoList[0].chargeStatus == "0" && array[index].chargerType == "1") {
                            $scope.isDCFree = "0";
                            $scope.isDCFreeNight = true;
                        }
                        //根据属性分别push
                        if (data.plugNoList[0].chargeStatus == "0") {
                            $scope.chargeStatusFree.push(data);
                        } else {
                            $scope.chargeStatusNo.push(data);
                        }
                    });
                    //根据serialNo排序
                    $scope.chargeStatusFree.sort(function(a, b) {
                        return Number(a.serialNo) > Number(b.serialNo) ? 1 : -1;
                    });
                    $scope.chargeStatusNo.sort(function(a, b) {
                        return Number(a.serialNo) > Number(b.serialNo) ? 1 : -1;
                    })
                    $scope.chargerList = $scope.chargeStatusFree.concat($scope.chargeStatusNo);
                }
            }
        })
    }
    $scope.getChargerListByStationId();
    //点击预约
    $scope.startrRservation = function(chargerId, chargeStatus) {
            var isLogin = localStorage.getItem("isLogin");
            if (isLogin == "true") {
                $q.all([pubFun.getPending(), pubFun.getOngoingOperation()]).then(function(data) {
                    if (globalFun.isEmptyObj(data[0]) == false) {
                        var notPayCardNo = data[0][0].orderNo;
                        $scope.weirdConfirmSet({
                            title: "",
                            content: "你有一个未支付的订单",
                            buttonAux: '取消',
                            buttonMain: '立即支付',
                            icon: "pending",
                            data: { type: "3", orderNo: notPayCardNo } //type: "1"，取消预约 "2"，结束充电 "3"，有未支付 "4"，有充电业务 "5"，有充预约务
                        });
                    } else if (globalFun.isEmptyObj(data[1].chargeList) == false) {
                        $scope.weirdConfirmSet({
                            title: "",
                            content: "您有一项充电任务正在进行中",
                            buttonAux: '取消',
                            buttonMain: '去看看',
                            icon: "charge",
                            data: { type: '4', msg: data[1].chargeList[0] } //type: "1"，取消预约 "2"，结束充电 "3"，有未支付 "4"，有充电业务 "5"，有充预约务
                        });
                    } else if (globalFun.isEmptyObj(data[1].reservationList) == false) {
                        $scope.weirdConfirmSet({
                            title: "",
                            content: "您有一项预约订单正在进行中",
                            buttonAux: '取消',
                            buttonMain: '去看看',
                            icon: "book",
                            data: { type: '5', msg: data[1].reservationList[0] } //type: "1"，取消预约 "2"，结束充电 "3"，有未支付 "4"，有充电业务 "5"，有充预约务
                        });
                    } else {
                        if (chargeStatus === '0') {
                            localStorage.setItem("charger_chargerId", chargerId);
                            window.location.href = mainConfig.hostUrl + "index.html#/beAppointing/" + chargerId;
                        } else {
                            Popup.notice("请选择空闲的充电桩", 3000);
                        }

                    }
                })

            } else {
                localStorage.setItem("state", 3)
                $rootScope.showLogin = true;
            }
        }
        // 收藏
    $scope.collect = function() {
        $rootScope.collectionStation($scope.stationId).then(function() {
            $scope.collectBtn = $scope.collectBtn == "收藏" ? "取消" : "收藏";
            if ($scope.collectBtn == "收藏") {
                $scope.activeStyle = 1;
                $scope.toastSet({
                    content: "已取消收藏"
                })
            } else {
                $scope.activeStyle = 0;
                $scope.toastSet({
                    content: "收藏成功"
                })
            }
        })
    };
    //导航
    $scope.naviGation = function(address) {
        var latitude = localStorage.getItem("latitude");
        var longitude = localStorage.getItem("longitude");
        window.location.href = "https://map.qq.com/m/mqq/nav/eword=" + address + "&epointx=" + longitude + "&epointy=" + latitude + "?referer=myapp&key=P44BZ-LANRX-D6I46-ZTXJL-OHJT2-LKBR3";
    }
});
